package cn.com.dcsgo.controller;

import cn.com.dcsgo.product.bean.Product;
import cn.com.dcsgo.service.ProductService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ProductController
 *
 * @author Dcsgo
 * @since 2025/3/11 9:38
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("product")
public class ProductController {
    private final ProductService productService;

    @GetMapping("{id}")
    public Product getProductById(@PathVariable("id") Long id, HttpServletRequest request) {
        String token = request.getHeader("token");
        log.info("被RPC了 token: {}", token);
        return productService.getById(id);
    }
}
